import React from 'react';
import { createBrowserRouter } from 'react-router-dom';
import Login from '@/pages/Login/index';
import Layout from '@/pages/Layout/index';
import AuthGuard from '@/components/AuthGuard';
import AdminGuard from '@/components/AdminGuard'; // 需要创建这个组件
import HomePage from '@/pages/Layout/HomePage';
import Search from '@/pages/Layout/Search';
import UserCenter from '@/pages/Layout/UserCenter';
import NotFound from '@/pages/NotFound';
import Cart from '@/pages/Layout/Cart';
import Notification from '@/pages/Layout/Notification';
import Orders from '@/pages/Layout/Orders';
import AdminNotification from '@/pages/Admin/Notification'; // 需要创建这个组件
import AdminProducts from '@/pages/Admin/Products'; // 需要创建这个组件
import AdminSettings from '@/pages/Admin/Settings'; // 需要创建这个组件
import CustomerServicePage from '@/pages/CustomerServicePage';


const router = createBrowserRouter([
  {
    path: '/',
    element: <AuthGuard />,
    children: [
      {
        path: '/',
        element: <Layout><HomePage /></Layout>
      },
      {
        path: '/home',
        element: <Layout><HomePage /></Layout>
      },
      {
        path: '/search',
        element: <Layout><Search /></Layout>
      },
      {
        path:'/notification',
        element:<Layout><Notification /></Layout>
      },
      {
        path:'/profile',
        element:<Layout><UserCenter /></Layout>
      },
      {
        path:'/cart',
        element:<Layout><Cart /></Layout>
      },
      {
        path:'/orders',
        element:<Layout><Orders /></Layout>
      },
      {
        path:'/customer-service',
        element:<Layout><CustomerServicePage /></Layout>
      },
      {
        path: '/admin',
        element: <AdminGuard />,
        children: [
          {
            path: 'notifications',
            element: <Layout><AdminNotification /></Layout>
          },
          {
            path: 'products',
            element: <Layout><AdminProducts /></Layout>
          },
          {
            path: 'settings',
            element: <Layout><AdminSettings /></Layout>
          }
        ]
      },
      {
        path:'*',
        element:<NotFound />
      },
    ]
  },
  {
    path: '/login',
    element: <Login />
  }
]);

export default router;